package com.example.nonacademic_education.dao;

import com.example.nonacademic_education.data.response.MsgRes;
import com.example.nonacademic_education.entity.Msg;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface MsgDao {
    List<MsgRes> getList(Integer page, Integer size, Long recipientId, String content, Integer isRead);

    Integer getNumber(Long recipientId, String content, Integer isRead);

    @Select("select m.*,a.name as senderName from msg m left join admin a on a.id =m.sender_id where m.recipient_id=#{recipientId} and m.is_read=0")
    List<MsgRes> getUnreadList(Long recipientId);

    Integer addOne(Msg msg);

    @Update("update msg set is_read=1 where id=#{msgId}")
    Integer readMsg(Long msgId);

    @Delete("delete from msg where id=#{msgId}")
    Integer deleteMsg(Long msgId);
}
